\(\int \cot (e+f x) (a+b \tan ^2(e+f x))^2 \, dx\) [201]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [B] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 21, antiderivative size = 51 \[ \int \cot (e+f x) \left (a+b \tan ^2(e+f x)\right )^2 \, dx=\frac {(a-b)^2 \log (\cos (e+f x))}{f}+\frac {a^2 \log (\tan (e+f x))}{f}+\frac {b^2 \tan ^2(e+f x)}{2 f} \]

[Out]

(a-b)^2*ln(cos(f*x+e))/f+a^2*ln(tan(f*x+e))/f+1/2*b^2*tan(f*x+e)^2/f

Rubi [A] (verified)

Time = 0.07 (sec) , antiderivative size = 51, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.143, Rules used = {3751, 457, 84} \[ \int \cot (e+f x) \left (a+b \tan ^2(e+f x)\right )^2 \, dx=\frac {a^2 \log (\tan (e+f x))}{f}+\frac {(a-b)^2 \log (\cos (e+f x))}{f}+\frac {b^2 \tan ^2(e+f x)}{2 f} \]

[In]

Int[Cot[e + f*x]*(a + b*Tan[e + f*x]^2)^2,x]

[Out]

((a - b)^2*Log[Cos[e + f*x]])/f + (a^2*Log[Tan[e + f*x]])/f + (b^2*Tan[e + f*x]^2)/(2*f)

Rule 84

Int[((e_.) + (f_.)*(x_))^(p_.)/(((a_.) + (b_.)*(x_))*((c_.) + (d_.)*(x_))), x_Symbol] :> Int[ExpandIntegrand[(
e + f*x)^p/((a + b*x)*(c + d*x)), x], x] /; FreeQ[{a, b, c, d, e, f}, x] && IntegerQ[p]

Rule 457

Int[(x_)^(m_.)*((a_) + (b_.)*(x_)^(n_))^(p_.)*((c_) + (d_.)*(x_)^(n_))^(q_.), x_Symbol] :> Dist[1/n, Subst[Int
[x^(Simplify[(m + 1)/n] - 1)*(a + b*x)^p*(c + d*x)^q, x], x, x^n], x] /; FreeQ[{a, b, c, d, m, n, p, q}, x] &&
 NeQ[b*c - a*d, 0] && IntegerQ[Simplify[(m + 1)/n]]

Rule 3751

Int[((d_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((a_) + (b_.)*((c_.)*tan[(e_.) + (f_.)*(x_)])^(n_))^(p_.), x_Symbol]
 :> With[{ff = FreeFactors[Tan[e + f*x], x]}, Dist[c*(ff/f), Subst[Int[(d*ff*(x/c))^m*((a + b*(ff*x)^n)^p/(c^2
 + ff^2*x^2)), x], x, c*(Tan[e + f*x]/ff)], x]] /; FreeQ[{a, b, c, d, e, f, m, n, p}, x] && (IGtQ[p, 0] || EqQ
[n, 2] || EqQ[n, 4] || (IntegerQ[p] && RationalQ[n]))

Rubi steps \begin{align*} \text {integral}& = \frac {\text {Subst}\left (\int \frac {\left (a+b x^2\right )^2}{x \left (1+x^2\right )} \, dx,x,\tan (e+f x)\right )}{f} \\ & = \frac {\text {Subst}\left (\int \frac {(a+b x)^2}{x (1+x)} \, dx,x,\tan ^2(e+f x)\right )}{2 f} \\ & = \frac {\text {Subst}\left (\int \left (b^2+\frac {a^2}{x}-\frac {(a-b)^2}{1+x}\right ) \, dx,x,\tan ^2(e+f x)\right )}{2 f} \\ & = \frac {(a-b)^2 \log (\cos (e+f x))}{f}+\frac {a^2 \log (\tan (e+f x))}{f}+\frac {b^2 \tan ^2(e+f x)}{2 f} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.14 (sec) , antiderivative size = 49, normalized size of antiderivative = 0.96 \[ \int \cot (e+f x) \left (a+b \tan ^2(e+f x)\right )^2 \, dx=\frac {2 \left ((a-b)^2 \log (\cos (e+f x))+a^2 \log (\tan (e+f x))\right )+b^2 \tan ^2(e+f x)}{2 f} \]

[In]

Integrate[Cot[e + f*x]*(a + b*Tan[e + f*x]^2)^2,x]

[Out]

(2*((a - b)^2*Log[Cos[e + f*x]] + a^2*Log[Tan[e + f*x]]) + b^2*Tan[e + f*x]^2)/(2*f)

Maple [A] (verified)

Time = 0.14 (sec) , antiderivative size = 49, normalized size of antiderivative = 0.96

method result size
parallelrisch \(\frac {-\left (a -b \right )^{2} \ln \left (\sec \left (f x +e \right )^{2}\right )+b^{2} \tan \left (f x +e \right )^{2}+2 a^{2} \ln \left (\tan \left (f x +e \right )\right )}{2 f}\) \(49\)
derivativedivides \(\frac {\frac {b^{2} \tan \left (f x +e \right )^{2}}{2}+a^{2} \ln \left (\tan \left (f x +e \right )\right )+\frac {\left (-a^{2}+2 a b -b^{2}\right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}}{f}\) \(58\)
default \(\frac {\frac {b^{2} \tan \left (f x +e \right )^{2}}{2}+a^{2} \ln \left (\tan \left (f x +e \right )\right )+\frac {\left (-a^{2}+2 a b -b^{2}\right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}}{f}\) \(58\)
norman \(\frac {b^{2} \tan \left (f x +e \right )^{2}}{2 f}+\frac {a^{2} \ln \left (\tan \left (f x +e \right )\right )}{f}-\frac {\left (a^{2}-2 a b +b^{2}\right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2 f}\) \(59\)
risch \(-i a^{2} x +2 i a b x -i b^{2} x +\frac {4 i a b e}{f}-\frac {2 i b^{2} e}{f}-\frac {2 i a^{2} e}{f}+\frac {2 b^{2} {\mathrm e}^{2 i \left (f x +e \right )}}{f \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right )^{2}}-\frac {2 \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) a b}{f}+\frac {\ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) b^{2}}{f}+\frac {a^{2} \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}-1\right )}{f}\) \(138\)

[In]

int(cot(f*x+e)*(a+b*tan(f*x+e)^2)^2,x,method=_RETURNVERBOSE)

[Out]

1/2*(-(a-b)^2*ln(sec(f*x+e)^2)+b^2*tan(f*x+e)^2+2*a^2*ln(tan(f*x+e)))/f

Fricas [A] (verification not implemented)

none

Time = 0.27 (sec) , antiderivative size = 69, normalized size of antiderivative = 1.35 \[ \int \cot (e+f x) \left (a+b \tan ^2(e+f x)\right )^2 \, dx=\frac {b^{2} \tan \left (f x + e\right )^{2} + a^{2} \log \left (\frac {\tan \left (f x + e\right )^{2}}{\tan \left (f x + e\right )^{2} + 1}\right ) - {\left (2 \, a b - b^{2}\right )} \log \left (\frac {1}{\tan \left (f x + e\right )^{2} + 1}\right )}{2 \, f} \]

[In]

integrate(cot(f*x+e)*(a+b*tan(f*x+e)^2)^2,x, algorithm="fricas")

[Out]

1/2*(b^2*tan(f*x + e)^2 + a^2*log(tan(f*x + e)^2/(tan(f*x + e)^2 + 1)) - (2*a*b - b^2)*log(1/(tan(f*x + e)^2 +
 1)))/f

Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 97 vs. \(2 (42) = 84\).

Time = 0.48 (sec) , antiderivative size = 97, normalized size of antiderivative = 1.90 \[ \int \cot (e+f x) \left (a+b \tan ^2(e+f x)\right )^2 \, dx=\begin {cases} - \frac {a^{2} \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 f} + \frac {a^{2} \log {\left (\tan {\left (e + f x \right )} \right )}}{f} + \frac {a b \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{f} - \frac {b^{2} \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 f} + \frac {b^{2} \tan ^{2}{\left (e + f x \right )}}{2 f} & \text {for}\: f \neq 0 \\x \left (a + b \tan ^{2}{\left (e \right )}\right )^{2} \cot {\left (e \right )} & \text {otherwise} \end {cases} \]

[In]

integrate(cot(f*x+e)*(a+b*tan(f*x+e)**2)**2,x)

[Out]

Piecewise((-a**2*log(tan(e + f*x)**2 + 1)/(2*f) + a**2*log(tan(e + f*x))/f + a*b*log(tan(e + f*x)**2 + 1)/f -
b**2*log(tan(e + f*x)**2 + 1)/(2*f) + b**2*tan(e + f*x)**2/(2*f), Ne(f, 0)), (x*(a + b*tan(e)**2)**2*cot(e), T
rue))

Maxima [A] (verification not implemented)

none

Time = 0.23 (sec) , antiderivative size = 59, normalized size of antiderivative = 1.16 \[ \int \cot (e+f x) \left (a+b \tan ^2(e+f x)\right )^2 \, dx=\frac {a^{2} \log \left (\sin \left (f x + e\right )^{2}\right ) - {\left (2 \, a b - b^{2}\right )} \log \left (\sin \left (f x + e\right )^{2} - 1\right ) - \frac {b^{2}}{\sin \left (f x + e\right )^{2} - 1}}{2 \, f} \]

[In]

integrate(cot(f*x+e)*(a+b*tan(f*x+e)^2)^2,x, algorithm="maxima")

[Out]

1/2*(a^2*log(sin(f*x + e)^2) - (2*a*b - b^2)*log(sin(f*x + e)^2 - 1) - b^2/(sin(f*x + e)^2 - 1))/f

Giac [A] (verification not implemented)

none

Time = 0.74 (sec) , antiderivative size = 86, normalized size of antiderivative = 1.69 \[ \int \cot (e+f x) \left (a+b \tan ^2(e+f x)\right )^2 \, dx=\frac {a^{2} \log \left (\sin \left (f x + e\right )^{2}\right ) - {\left (2 \, a b - b^{2}\right )} \log \left ({\left | \sin \left (f x + e\right )^{2} - 1 \right |}\right ) + \frac {2 \, a b \sin \left (f x + e\right )^{2} - b^{2} \sin \left (f x + e\right )^{2} - 2 \, a b}{\sin \left (f x + e\right )^{2} - 1}}{2 \, f} \]

[In]

integrate(cot(f*x+e)*(a+b*tan(f*x+e)^2)^2,x, algorithm="giac")

[Out]

1/2*(a^2*log(sin(f*x + e)^2) - (2*a*b - b^2)*log(abs(sin(f*x + e)^2 - 1)) + (2*a*b*sin(f*x + e)^2 - b^2*sin(f*
x + e)^2 - 2*a*b)/(sin(f*x + e)^2 - 1))/f

Mupad [B] (verification not implemented)

Time = 12.06 (sec) , antiderivative size = 62, normalized size of antiderivative = 1.22 \[ \int \cot (e+f x) \left (a+b \tan ^2(e+f x)\right )^2 \, dx=\frac {b^2\,{\mathrm {tan}\left (e+f\,x\right )}^2}{2\,f}-\frac {\ln \left ({\mathrm {tan}\left (e+f\,x\right )}^2+1\right )\,\left (\frac {a^2}{2}-a\,b+\frac {b^2}{2}\right )}{f}+\frac {a^2\,\ln \left (\mathrm {tan}\left (e+f\,x\right )\right )}{f} \]

[In]

int(cot(e + f*x)*(a + b*tan(e + f*x)^2)^2,x)

[Out]

(b^2*tan(e + f*x)^2)/(2*f) - (log(tan(e + f*x)^2 + 1)*(a^2/2 - a*b + b^2/2))/f + (a^2*log(tan(e + f*x)))/f